<?php

namespace App\Admin\Extensions\Nav;

class Common
{
    public function __toString()
    {
        return <<<HTML
<script >
    function allocation_page_search(page){

           var seacher_material_code = $("#seacher_material_code").val();
           var seacher_material_name = $("#seacher_material_name").val();

           $.ajax({
              type: 'get',
              async: false,
              url: "/admin/data/get/material/list",
              data: {seacher_material_code:seacher_material_code,seacher_material_name:seacher_material_name,page:page},
              dataType: 'json',
              success: function (data) {
                 var str="";
                 var material_list = data.material_list;

                 for(var i=0;i<material_list.length;i++){
                    str+='<tr id="material_key'+material_list[i]['id']+'">';
                    str+='<td><input type="checkbox" class="material_key" name="id" value="'+material_list[i]['id']+'"></td>';
                    str+='<td class="column-material_code">'+material_list[i]['material_code']+'</td>';
                    str+='<td class="column-material_name">'+material_list[i]['material_name']+'</td>';
                    str+='<td class="column-material_category_name">'+material_list[i]['material_category_name']+'</td>';
                    str+='<td class="column-unit_name">'+material_list[i]['unit_name']+'</td>';
                    str+='<td class="column-material_alias_one">'+material_list[i]['material_alias_one']+'</td>';
                    str+='<td class="column-specifications">'+material_list[i]['specifications']+'</td>';
                    str+='</tr>';
                 }

                 $("#material_list_data").html(str);

                 var pages = data.pages;
                 var page_str='<li class="page-item disabled"><span class="page-link">«</span></li>';
                 for(var i=1;i<=pages;i++) {
                    if(i==data.select_page){
                       page_str+='<li class="page-item active" style="cursor:pointer"><span class="page-link">'+i+'</span></li>';
                    }else{
                       page_str+='<li class="page-item" style="cursor:pointer" value="'+i+'" onclick="allocation_page_search('+i+')"><span class="page_search page-link">'+i+'</span></li>';
                    }
                 }
                 page_str+='<li class="page-item disabled"><span class="page-link">»</span></li>';
                 $("#pages").html(page_str);

                 $("#material_count").html(data.count);
              }
           });
    }
   function allocation_remover(id){
        $(".diaobo"+id).html(' ');
    }

     function fixed_remover(id){
        $(".fixed_remover"+id).html(' ');
    }
</script>

HTML;
    }
}